package com.jiyang.rpidisplay;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

/**
 * -------------------------------
 * Created by JiYang on 3/6/18.
 * -------------------------------
 */

public class SettingActivity extends AppCompatActivity {
    private EditText et;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        et = findViewById(R.id.etUrl);
        findViewById(R.id.btnOk).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                saveUrl();
            }
        });
    }

    private void saveUrl() {
        String url = et.getText().toString();
        et.setHint(url);
        if (!TextUtils.isEmpty(url)) {
            SPUtil.saveString(this, "url", url);
        }
        finish();
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, SettingActivity.class);
        context.startActivity(intent);
    }
}
